package model;

import java.util.Arrays;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

public class EmpTableModel extends AbstractTableModel {
	private static final long serialVersionUID = 3099768691830690602L;
	private Vector<Object> data;
	private Vector<String> columnnames = new Vector<String>(Arrays.asList(
			"STT", "M\u00E3 NV", "T\u00EAn NV", "Ch\u1EE9c v\u1EE5",
			"Ng\u00E0y  l\u00E0m", "\u0110i\u1EC7n tho\u1EA1i"));

	public EmpTableModel(Vector<Object> data, Vector<?> columnnames) {
		this.data = data;
	}

	@Override
	public boolean isCellEditable(int row, int column) {
		return false;
	}

	@Override
	public Object getValueAt(int row, int column) {
		Employee e = (Employee) data.get(row);

		switch (column) {
		case 0:
			return row + 1;
		case 1:
			return e.getId();
		case 2:
			return e.getName();
		case 3:
			return e.getRegency();
		case 4:
			return e.getDateBegin();
		case 5:
			return e.getPhone();
		}
		return null;
	}

	@Override
	public int getRowCount() {
		if (data == null)
			return 0;
		return data.size();
	}

	@Override
	public int getColumnCount() {
		return columnnames.size();
	}

	public void setDataVector(Vector<Object> data, Vector<String> columnnames) {
		this.data = data;
	}

	@Override
	public String getColumnName(int column) {
		return columnnames.get(column);
	}

}
